package com.googlecode.javatools.classparser.types.impl;

import java.util.List;

import com.googlecode.javatools.classparser.types.ClassInfo;

public class ClassInfoImpl implements ClassInfo
{
	private final boolean isClassAbstract;
	private final boolean isInterface;
	private final String fullyQualifiedClassName;
	private final String fullyQualifiedSuperClassName;
	private final List<String> interfaceNames;
	private final boolean isPublic;

	public ClassInfoImpl(final String fullyQualifiedClassName, final String fullyQualifiedSuperClassName,
			final List<String> interfaceNames, final boolean isClassAbstract, final boolean isInterface,
			final boolean isPublic)
	{
		this.fullyQualifiedClassName = fullyQualifiedClassName;
		this.fullyQualifiedSuperClassName = fullyQualifiedSuperClassName;
		this.interfaceNames = interfaceNames;
		this.isClassAbstract = isClassAbstract;
		this.isInterface = isInterface;
		this.isPublic = isPublic;
	}

	public boolean isAbstract()
	{
		return isClassAbstract;
	}

	public boolean isInterface()
	{
		return isInterface;
	}

	public boolean isPublic()
	{
		return isPublic;
	}

	public String fullyQualifiedClassName()
	{
		return fullyQualifiedClassName;
	}

	public String className()
	{
		return classOf(fullyQualifiedClassName);
	}

	public String packageName()
	{
		return packageOf(fullyQualifiedClassName);
	}

	public String fullyQualifiedSuperClassName()
	{
		return fullyQualifiedSuperClassName;
	}

	public String superClassName()
	{
		return classOf(fullyQualifiedSuperClassName);
	}

	public String superPackageName()
	{
		return packageOf(fullyQualifiedSuperClassName);
	}

	public List<String> interfaces()
	{
		return interfaceNames;
	}

	private static String packageOf(final String fullyQualifiedClassName)
	{
		return fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf("."));
	}

	private static String classOf(final String fullyQualifiedClassName)
	{
		return fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1, fullyQualifiedClassName
				.length());
	}
}
